const { list } = require('./src/mock')
const bodyParser = require('body-parser')
module.exports = {
  devServer: {
    before(app) {
      app.use(bodyParser.json())
      app.get('/api/list', (req, res) => {
        const { pageIndex = 0, pageSize = 10 } = req.query;  
        setTimeout(() => {
          res.send({
            code: 200,
            data: list.slice(pageIndex * pageSize, (+pageIndex + 1) * pageSize)
          })
        }, Math.random() * 2000)
      })
    }
  }
}